fix(sonar): handle app.whenReady rejection on startup (typescript:S9383) - #3380
Merged
Merged
Conversation
Replace the bare 'void' on the app.whenReady().then(...) startup chain with a .catch handler that logs startup failures via electron-log. A rejection in onFirstRunMaybe() (which awaits dialog.showMessageBox) or any register*/initialize handler would otherwise be left unhandled in the main process, silently skipping IPC handler registration or crashing the app depending on Node's unhandled-rejection mode.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
typescript:S9383— the module-level startup promise chain insrc/main/index.tsused a barevoid app.whenReady().then(...), which leaves any rejection unhandled in the main process.If
onFirstRunMaybe()rejects (it awaitsdialog.showMessageBox()andapp.moveToApplicationsFolder()), or anyregister*Handlers/initializeAppLifecycle/configureWindowEventscall throws, the rejection goes unhandled: the error skips the app logger, remaining IPC/tray handlers silently never register, and depending on Node's unhandled-rejection mode the app can crash.This is the same pattern Gitar flagged on the parallel atlassify PR (#setchy/atlassify#3793) and matches the
.catch+toErrorconvention already used across gitify'smenu.ts,updater.ts, andutils.ts.Changes
src/main/index.ts: replaced barevoid app.whenReady().then(...)with a.catchhandler that logs vialogError('main', 'Failed to initialize application', toError(err)); added thelogError/toErrorimport.src/main/index.test.ts(new): covers the menubar config, ozone-before-ready ordering, and the new rejection path (logs an error whenwhenReadyrejects).Verification
pnpm test— 1838/1838 passing (185 files)pnpm exec tsc --noEmit— cleanpnpm exec vp lint— cleanSonar issues: https://sonarcloud.io/project/issues?id=gitify-app_gitify&rules=typescript%3AS9383&issueStatuses=OPEN%2CCONFIRMED